package com.wonders.bigdata.easyExcel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;

import java.util.List;

/**
 * @author xb
 * @descripton:
 * @date 2023/6/24
 */
public class ExcelImport {
    public static void main(String[] args) {
        try {
            String path = "D:/file/需求稿1.xlsx";
            ExcelReader reader = EasyExcel.read(path).build();
            List<ReadSheet> sheets = reader.excelExecutor().sheetList();
            for (int i = 0; i < sheets.size(); i++) {
                ReadSheet readSheet = sheets.get(i);
                System.out.println("表序号：" + readSheet.getSheetNo());
                System.out.println("表名：" + readSheet.getSheetName());
                List<Object> objects = EasyExcel.read(path).sheet(i).doReadSync();
                objects.forEach(System.out::println);
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
